#! /usr/bin/bash

awk -F '\t' '
    BEGIN{
        mark=0
        } \
    $1 ~ /([cC]hr)?3/ && \
    $2 <= 20147100 && \
    $3 >= 20034100 && \
    $5 ~ /-/ \
    {
        mark++;
        printf "3\t%s\t%s\t%s\t%s\n", $2, $3, $4, $5
        } \
    END{
        printf "# geneX: %s; total: %s\n", mark, NR
        } \
    ' 'chr.bed' | tac > 'geneX.bed'
